<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 300px;
        height: 300px;
        background-color: skyblue;
      }
    </style>
  </head>
  <body>
    <div class="box"></div>
    <script>
      //1.获取元素
      var box = document.querySelector('.box');
      var ft = true;
      //2.点击事件
      box.onclick = function () {
        //  box.style.width = '500px';
        //如果css以前是链接属性    在JS 中要使用驼峰命名法

        if (ft) {
          this.style.backgroundColor = 'pink';
          ft = false;
        } else {
          this.style.backgroundColor = '';
          ft = true;
        }

        // box.style.backgroundColor = 'pink';
      };
    </script>
  </body>
</html>
